import React, { Component } from 'react'
import Styles from './index.less'
import { withRouter } from 'react-router-dom'
// import { Link } from 'react-router-dom'
@withRouter
class NewsSection extends Component {
    constructor() {
        super()
    }
    skipToDetail(id, type) {
        let listInfo = {
            pageNo: this.props.pageNo,
            scrollTop: document.documentElement.scrollTop || window.pageYOffset || document.body.scroll,
            tabIndex: type - 1
        }
        sessionStorage.setItem('listInfo', JSON.stringify(listInfo))
        this.props.history.push(`/newsDetail/${id}/${type}`)
    }
    render() {
        const { title, abstract, footer, id, type } = this.props
        const pic = type == 1 ? '/static/image/news1.jpg' : type == 2 ? '/static/image/news2.png' : '/static/image/news3.png'
        return (
            <div className={Styles.newsSection}>
                <div className={Styles.newsMainContainer}>
                    <span className={Styles.newsTitle} onClick={this.skipToDetail.bind(this, id, type)}>{title}</span>
                    <span className={Styles.newsMain} onClick={this.skipToDetail.bind(this, id, type)}>{abstract}</span>
                    {footer}
                </div>
                <img src={pic} className={Styles.newsPic}/>
            </div>
        )
    }
}
export default NewsSection